#!/usr/bin/env bash
#!/bin/bash

set -e

curr_user=`whoami`
if [ $curr_user != "root" ];then
    echo "please login by root and execute this script"
    exit 1
fi

curr_time_str=$(date "+%Y%m%d%H%M")
file_name=skynet-manager-prod-1.7.9.RELEASE.jar
backend_path=/apps/srv/instance/skynet-manager/backend
origin_file_path=${backend_path}/skynet-manager-prod-1.7.9.RELEASE.jar
target_file_path=${backend_path}/bak${curr_time_str}-skynet-manager-prod-1.7.9.RELEASE.jar
# 备份原文件
cp ${origin_file_path} ${target_file_path}
# 拷贝新上传文件替换原文件
mv /home/kuaike/${file_name} ${origin_file_path}
sh ${backend_path}/restart.sh

echo "/apps/srv/instance/skynet-manager/backend/logs/info.log"